package com.kedacom.freedomLabel.model.db.dao;

import android.arch.persistence.room.Dao;
import android.arch.persistence.room.Delete;
import android.arch.persistence.room.Insert;
import android.arch.persistence.room.OnConflictStrategy;
import android.arch.persistence.room.Query;
import android.arch.persistence.room.Update;

import com.kedacom.freedomLabel.model.bean.Operator;

import java.util.List;

/**
 * Author：李程
 * CreateTime：2020/6/5 00:42
 * E-mail：licheng@kedacom.com
 * Describe：
 */
@Dao
public interface OperatorDao extends IDao<Operator> {

    @Override
    @Query("SELECT COUNT(0) FROM operator")
    int count();

    @Override
    @Update
    void update(Operator category);

    @Override
    @Insert(onConflict = OnConflictStrategy.FAIL)
    long save(Operator item);

    @Override
    @Insert(onConflict = OnConflictStrategy.FAIL)
    long[] save(List<Operator> items);

    @Override
    @Query("SELECT * FROM operator ORDER BY createTime DESC")
    List<Operator> get();

    @Override
    @Query("SELECT * FROM operator WHERE cardNumber =:cardNumber ORDER BY createTime DESC")
    List<Operator> get(String cardNumber);

    @Override
    @Query("SELECT * FROM operator WHERE cardNumber =:cardNumber OR (shortHand LIKE :keyword OR cardNumber LIKE :keyword) ORDER BY createTime DESC")
    List<Operator> get(String cardNumber, String keyword);

    @Override
    @Delete
    void delete(Operator item);

    @Override
    @Query("DELETE FROM operator")
    void delete();

    @Override
    @Query("DELETE FROM Item WHERE category =:param")
    void delete(String param);

}